package com.ruoyi.system.api.factory;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.RemoteHumanClinicalTrialService;
import com.ruoyi.system.api.domain.HumanClinicalTrial;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class RemoteHumanClinicalTrialFallbackFactory implements FallbackFactory<RemoteHumanClinicalTrialService> {
    private static final Logger log= LoggerFactory.getLogger(RemoteHumanClinicalTrialFallbackFactory.class);
    @Override
    public RemoteHumanClinicalTrialService create(Throwable throwable) {
        log.error("临床试验服务调用失败:{}",throwable.getMessage());
        System.out.println("临床试验服务调用失败:"+throwable.getMessage());
        return new RemoteHumanClinicalTrialService() {
            @Override
            public R<HumanClinicalTrial> getTrialInfo(Long trialId) {
                return R.fail("获取临床试验信息失败:"+throwable.getMessage());
            }
        };
    }
}
